.sidenav-tree {
    width: 300px;

    .control-toolbar {
        padding: 0;

        .toolbar-item {
            display: block;
        }

        input.form-control {
            border: none;
            outline: none;
            padding: 12px 13px 13px;
            .border-radius(0);
            .box-shadow(inset -3px 0 3px rgba(0,0,0,0.1));

            &.search {
                background-position: right -78px;
            }
        }
    }

    ul {
        padding: 0;
        margin: 0;
        list-style: none;
    }

    div.scrollbar-thumb {
        background: rgba(0,0,0,.2) !important;
    }

    ul.top-level > li {
        &[data-status=collapsed] {
            > div.group {
                h3:before {
                    .transform(~'rotate(0deg) translate(2px, -2px)');
                }

                // Hide triangle
                &:before, &:after {
                    display: none;
                }
            }

            ul {
                display: none;
            }
        }

        > div.group {
            position: relative;

            h3 {
                background: @color-sidebarnav-tree-group-bg;
                color: @color-sidebarnav-tree-group;
                text-transform: uppercase;
                font-size: 15px;
                padding: 15px 15px 15px 40px;
                margin: 0;
                position: relative;
                cursor: pointer;
                font-weight: 400;

                &:before {
                    display: block;
                    position: absolute;
                    width: 10px;
                    height: 10px;
                    left: 16px;
                    top: 15px;
                    color: @color-list-arrow;
                    .icon(@angle-right);
                    .transform(~'rotate(90deg) translate(5px, -3px)');
                    .transition(all 0.1s ease);
                    font-size: 16px;
                }
            }

            // Use two triangles to achieve the darkening effect
            &:before,
            &:after {
                .triangle(down, 15px, 8px, @brand-primary);
                position: absolute;
                left: 15px;
                bottom: -8px;
                z-index: 101;
            }

            &:after {
                .triangle(down, 15px, 8px, @color-sidebarnav-tree-group-bg);
            }
        }

        > ul {
            li {

                a {
                    display: block;
                    position: relative;
                    padding: 18px 25px 18px 55px;
                    background: @color-sidebarnav-tree-inactive-bg;
                    border-bottom: 1px solid @color-sidebarnav-tree-group-bg;
                    color: @color-sidebarnav-tree-inactive-text;
                    text-decoration: none !important;
                    .opacity(.65);

                    &:active,
                    &:hover {
                        .opacity(1);
                        text-decoration: none;
                    }

                    i {
                        position: absolute;
                        left: 16px;
                        top: 18px;
                        font-size: 22px;
                    }

                    span {
                        display: block;
                        line-height: 150%;

                        &.header {
                            color: @color-sidebarnav-tree-inactive-header;
                            font-size: @font-size-base + 1;
                            margin-bottom: 5px;
                        }

                        &.description {
                            color: @color-sidebarnav-tree-inactive-desc;
                            font-size: @font-size-base - 1;
                        }
                    }
                }

                &:hover a,
                &.active a {
                    .opacity(1);
                }

                &.active {
                    border-left: 5px solid @brand-secondary;

                    a {
                        color: @color-sidebarnav-tree-active-text;
                        padding-right: 20px;

                        span.header {
                            color: @color-sidebarnav-tree-active-header;
                        }

                        span.description {
                            color: @color-sidebarnav-tree-active-text;
                        }
                    }
                }

                // &:last-child a {
                //     border-bottom: none;
                // }
            }
        }
    }

    .back-link {
        display: none;
    }
}

@media (min-width: @screen-sm-min) {
    .sidenav-tree-root .sidenav-tree {
        width: 600px;

        ul.top-level > li > ul {
            font-size: 0;
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: flex-start;
            align-items: stretch;
            align-content: stretch;

            > li {
                display: inline-block;
                // flex-grow: 1;
                width: 300px;

                a {
                    height: 100%;
                }
            }
        }
    }
}

@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) {
    .sidenav-tree-root .sidenav-tree {
        width: 100%;

        ul.top-level > li > ul > li {
            width: 50%;
        }
    }
}

@media (min-width: @screen-lg-min) {
    .sidenav-tree-root .sidenav-tree {
        width: 900px;
    }
}

@media (max-width: @screen-sm) {
    .sidenav-tree {
        width: 100%;
        height: auto !important;
        display: block !important;

        > .layout {
            display: none;
        }
    }

    .sidenav-tree-root {
        .sidenav-tree {
            width: 100% !important;
            height: 100% !important;
            display: table-cell !important;

            .back-link {
                display: none !important;
            }

            > .layout {
                display: table !important;
            }
        }

        #layout-body {
            display: none;
        }
    }

    body.has-sidenav-tree {
        .sidenav-tree {
            .back-link {
                display: block;
                padding: 13px 15px;
                background: @color-sidebarnav-back-link-bg;
                color: @color-sidebarnav-back-link-text;
                font-size: 14px;
                line-height: 14px;
                text-transform: uppercase;
                i {
                    display: inline-block;
                    margin-right: 10px;
                }
                &:hover {
                    text-decoration: none;
                }
            }
        }

        #layout-body {
            display: block !important;
        }
    }
}
